import { defineConfig } from "vite"
import tailwindcss from "@tailwindcss/vite"
import vue from "@vitejs/plugin-vue"

import path from "path"

// https://vite.dev/config/
export default defineConfig(({ mode }) => {
  return {
    plugins: [vue(), tailwindcss()],
    resolve: {
      alias: {
        "@": path.resolve(__dirname, "src"),
      },
    },
    // 动态 base 路径
    base: mode === "production" ? "/your-production-base/" : "/",
    build: {
      sourcemap: mode !== "production", // 生产关闭 sourcemap
      minify: mode === "production",
    },
    define: {
      __APP_ENV__: JSON.stringify(mode),
    },
  }
})
